/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo360.mobilesafe.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.AssetManager;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStream;

public class SharedPref {
    private static final String TAG = "SharedPref";
    private static final String PREF_NAME = "cleardex_time_lastupdate";
    public static final String KEY_CLEAR_UPDATE = "key_lastupdate";

    public static long getGzipVersion(Context paramContext, String paramString) {
        FileInputStream localFileInputStream = null;
        try {
            localFileInputStream = paramContext.openFileInput(paramString + ".ver");
        } catch (Exception localException) {}
        if (localFileInputStream != null)
            return getTimestampFromStream(localFileInputStream);
        return 0L;
    }

    private static long getTimestampFromStream(InputStream paramInputStream) {
        DataInputStream localDataInputStream = null;
        try {
            localDataInputStream = new DataInputStream(paramInputStream);
            String str = localDataInputStream.readLine();
            long l = Long.parseLong(str);
            return l;
        } catch (Exception localException1) {} finally {
            try {
                if (localDataInputStream != null)
                    localDataInputStream.close();
                if (paramInputStream != null)
                    paramInputStream.close();
            } catch (Exception localException4) {}
        }
        return 0L;
    }

    public static long getBundleVersion(Context paramContext, String paramString) {
        InputStream localInputStream = null;
        try {
            localInputStream = paramContext.getAssets().open(paramString + ".ver");
        } catch (Exception localException) {}
        if (localInputStream != null)
            return getTimestampFromStream(localInputStream);
        return 0L;
    }

    public static long getLong(Context paramContext, String paramString, long paramLong) {
        SharedPreferences localSharedPreferences = paramContext.getApplicationContext().getSharedPreferences(
                "cleardex_time_lastupdate", 0);
        return localSharedPreferences.getLong(paramString, paramLong);
    }

    public static boolean setLong(Context paramContext, String paramString, long paramLong) {
        SharedPreferences.Editor localEditor = paramContext.getApplicationContext()
                .getSharedPreferences("cleardex_time_lastupdate", 0).edit();
        localEditor.putLong(paramString, paramLong);
        return localEditor.commit();
    }
}